import axios from 'axios'

const BASE_URL = 'http://toutiao.itheima.net/v1_0/'
// const BASE_URL = 'http://geek.itheima.net/v1_0/'

// 创建http实例
const http = axios.create({
  baseURL: BASE_URL,
  timeout: 5000
})

// 添加请求拦截器
http.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

// 添加响应拦截器
http.interceptors.response.use(
  response => {
    return response
  },
  error => {
    return Promise.reject(error)
  }
)

export default http
